//
//  JHStatusViewModel.swift
//  JHSinaWeibo
//
//  Created by apple on 16/6/12.
//  Copyright © 2016年 apple. All rights reserved.
//  处理cell显示的模型数据
//  通过一个模型中存储的数据 将不能狗直接显示的数据 在viewModel中处理完成

import UIKit

class JHStatusViewModel: NSObject {
    var status:JHStatus?
    //认证类型图片
    var verifiedImage:UIImage?
    var mbrankImage:UIImage?
    var headImageURL:NSURL?
    //视图初始化
    init(status:JHStatus) {
        super.init()
        self.status = status
        //处理用户头像的地址
        headImageURL = NSURL(string:status.user?.profile_image_url ?? "")
        //处理认证类型的图片
        dealverifiedImage()
        //处理用户等级的图片
        dealmbrankImage()
    }
}
    extension JHStatusViewModel{
    private func dealverifiedImage(){
    let verifiedType = status?.user?.verified ?? 0
        if verifiedType == 1 {
           verifiedImage  = UIImage(named: "avatar_vip")
        }
    }
    private func dealmbrankImage(){
        let mbrankType = status?.user?.mbrank ?? 0
        if mbrankType > 0 && mbrankType < 7  {
            mbrankImage = UIImage(named: "common_icon_membership_level\(mbrankType)")
        }
        }
}

